/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.senai.relatorio;

import br.com.senai.config.Config;
import java.sql.SQLException;
import java.util.Date;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.view.JasperViewer;

/**
 *
 * @author Hugo
 */
public class GerarRelatorio {

    public void gerarRelatorioGeral(Date dataInicio, Date dataTermino) {

        HashMap mapa = new HashMap();

        mapa.put("DATA_INICIO", dataInicio);
        mapa.put("DATA_TERMINO", dataTermino);

        String arquivo = "relatorioPadraoPaes.jasper";

        try {
            JasperPrint jp = JasperFillManager.fillReport(arquivo, mapa, Conexao.getConnection());
          // JasperViewer.viewReport(jp, false);
           
           JasperViewer jv = new JasperViewer(jp, false);
           jv.setTitle(Config.NOME_SISTEMA + "| Relatório Geral");
           jv.setIconImage(Config.LOGO_SISTEMA);
           jv.setVisible(true);
           

        } catch (JRException | SQLException | ClassNotFoundException ex) {
            Logger.getLogger(GerarRelatorio.class.getName()).log(Level.SEVERE, null, ex);
        }

    }
    
        public void gerarRelatorioPorEscolas(Date dataInicio, Date dataTermino) {

        HashMap mapa = new HashMap();

        mapa.put("DATA_INICIO", dataInicio);
        mapa.put("DATA_TERMINO", dataTermino);

        String arquivo = "relatorioPorEscolas.jasper";

        try {
            JasperPrint jp = JasperFillManager.fillReport(arquivo, mapa, Conexao.getConnection());
        
           
           JasperViewer jv = new JasperViewer(jp, false);
           jv.setTitle(Config.NOME_SISTEMA + "| Relatório por escolas");
           jv.setIconImage(Config.LOGO_SISTEMA);
           jv.setVisible(true);
           

        } catch (JRException | SQLException | ClassNotFoundException ex) {
            Logger.getLogger(GerarRelatorio.class.getName()).log(Level.SEVERE, null, ex);
        }

    }



}
